﻿using System;
using System.Collections.Generic;

namespace YArchitech.Temp
{
	public class HYFlexDuct : HYPipeline
	{
		public HYShapeProfile Shape
		{
			get
			{
				return (this.m_Section as HYDuctSpecification).Shape;
			}
			set
			{
				(this.m_Section as HYDuctSpecification).Shape = value;
			}
		}

		public string ShapeString
		{
			get
			{
				return (this.m_Section as HYDuctSpecification).ShapeString;
			}
		}

		public int Width
		{
			get
			{
				return (this.m_Section as HYDuctSpecification).Width;
			}
			set
			{
				(this.m_Section as HYDuctSpecification).Width = value;
			}
		}

		public int Height
		{
			get
			{
				return (this.m_Section as HYDuctSpecification).Height;
			}
			set
			{
				(this.m_Section as HYDuctSpecification).Height = value;
			}
		}

		public int Diameter
		{
			get
			{
				return (this.m_Section as HYDuctSpecification).Diameter;
			}
			set
			{
				(this.m_Section as HYDuctSpecification).Diameter = value;
			}
		}

		public bool IsLinkTerminal
		{
			get
			{
				return base.Next != null && base.Next is HYDuctTerminal;
			}
		}

		public HYFlexDuct()
		{
			base.Name = "管段";
			this.m_Section = new HYDuctSpecification(HYShapeProfile.Rectangular, 800, 320);
		}

		public bool AddTaper(HYDuctTaper taper)
		{
			if (this.m_tapers == null)
			{
				this.m_tapers = new SortedSet<HYDuctTaper>();
			}
			this.m_tapers.Add(taper);
			taper.Previous = this;
			taper.Place = HYMEPObject.Down(base.Place);
			return true;
		}

		public bool HasTaper
		{
			get
			{
				return this.m_tapers != null && this.m_tapers.Count > 0;
			}
		}

		public ICollection<HYDuctTaper> Tapers
		{
			get
			{
				return this.m_tapers;
			}
		}

		public override void RebuildIndex(ref int index)
		{
			base.RebuildIndex(ref index);
			if (this.HasTaper)
			{
				foreach (HYDuctTaper hyductTaper in this.m_tapers)
				{
					hyductTaper.RebuildIndex(ref index);
				}
			}
		}

		public override void ReAllocateFlow()
		{
			base.ReAllocateFlow();
			double num = 0.0;
			if (this.HasTaper)
			{
				foreach (HYDuctTaper hyductTaper in this.m_tapers)
				{
					hyductTaper.ReAllocateFlow();
					num += hyductTaper.Flow;
				}
			}
			base.Flow += num;
		}

		protected void ReCalCoefficient()
		{
			this.m_Coefficient = 0.0;
		}

		public override void Cal(HYSystemOption option)
		{
			base.Cal(option);
		}

		private SortedSet<HYDuctTaper> m_tapers;
	}
}
